package com.mitcub.panda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mitcub.panda.base.BaseQuery;
import com.mitcub.panda.base.BaseServiceImpl;
import com.mitcub.panda.entity.Order;
import com.mitcub.panda.mapper.OrderMapper;
import com.mitcub.panda.query.OrderQuery;
import com.mitcub.panda.service.IOrderService;
import com.mitcub.panda.utils.RespResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @项目名称: panda
 * @类名称: OrderServiceImpl
 * @类描述: 支付订单 服务实现类
 * @作者: tangloong
 * @创建时间: 2021/11/13 17:22
 */
@Service
public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implements IOrderService {

    @Resource
    private OrderMapper orderMapper;

    /**
     * 获取数据列表
     * @param query 查询条件  订单号 用户昵称 状态
     * @return
     */
    @Override
    public RespResult getList(BaseQuery query) {
        OrderQuery memberQuery = (OrderQuery) query;
        // 查询条件
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();

        // 状态：1正常 2禁用
        if (memberQuery.getStatus() != null) {
            queryWrapper.eq("status", memberQuery.getStatus());
        }
        queryWrapper.eq("mark", 1);
        queryWrapper.orderByDesc("id");

        // 查询数据
        Page<Order> page = new Page<>(memberQuery.getPage(), memberQuery.getLimit());
        IPage<Order> data = orderMapper.selectPage(page, queryWrapper);
        return RespResult.success("操作成功", data.getRecords(),data.getTotal());
    }



}